;;; Copyright (c) 1999 Massachusetts Institute of Technology
;;;
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License as
;;; published by the Free Software Foundation; either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;;; General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, see https://gnu.org/licenses or
;;; write to:
;;;  Free Software Foundatiom, Inc.
;;;  51 Franklin St, Fifth Floor
;;;  Boston, MA 02110-1301
;;;  USA

.AUXIL

;ALLOW USER TO USE SYMBOLS IN OTHER WAYS IF HE WISHES.
;BUT NORMALLY, DEFSYM FOO==BAR DOES FOO==BAR WITH ERROR CHECK.

IFNDEF DEFSYM,[
DEFINE DEFSYM X/
IRPS Z,,[X]
IFNDEF Z,X
.ELSE [
   $$TEM1==Z
   X
   IFN Z-$$TEM1,.ERR Z MULTIPLY .QUOTE`.QUOTE/DEFINED/`
]
.ISTOP
TERMIN TERMIN

IFLE .MLLIT,.ERR .MLLIT MUST BE 1; SETTING IT TO 1.
.MLLIT==1
$$TEMP==1
];IF Not DEFined DEFSYM
.ELSE $$TEMP==0


;DISK PHYSICAL PARAMETERS (RH10 CONTROLLER)

DEFSYM	NCYLS==406.		;# CYLINDERS NORMALLY USED
DEFSYM	XCYLS==411.-NCYLS	;# CYLINDERS FOR SPARES, HACKS, ETC.
DEFSYM	NHEDS==19.		;# TRACKS/CYLINDER
DEFSYM	NSECS==20.		;# SECTORS/TRACK
DEFSYM	SECBLK==8		;# SECTORS/BLOCK
DEFSYM	NBLKSC==NHEDS*NSECS/SECBLK ;# BLOCKS/CYLINDER
DEFSYM	NBLKS==NCYLS*NBLKSC	;# BLOCKS NORMALLY USED
DEFSYM	XBLKS==XCYLS*NBLKSC	;# BLOCKS FOR HACKS
DEFSYM	TBLKS==NBLKS+XBLKS	;TOTAL BLOCKS

DEFSYM	NTUTBL==2		;2 BLOCKS PER TUT
DEFSYM	DECADE==NBLKSC		;NUMBER OF BLOCKS TO ALLOCATE AT A TIME
				;QSWAPA AND QLASTB MUST BE MULTIPLES OF THIS.
				;DECADE SIZE = CYLINDER SIZE FOR KLFEDR'S SAKE
DEFSYM	DSK=270			;I/O DEVICE NUMBER OF RH10

;CONI - LEFT HALF (ERROR BITS ONLY)

DEFSYM	%HID22==4000,,	;4.3 1=>22-BIT DATA CHANNEL, 0=>18-BIT
DEFSYM	%HIILF==400,,	;3.9 ILLEGAL FUNCTION CODE IN CONTROL REGISTER
DEFSYM	%HISDE==200,,	;3.8 SELECTED DRIVE PREVIOUS ERROR NOT RESET
DEFSYM	%HIDPE==4,,	;3.3 CHANNEL DATA PARITY ERROR
DEFSYM	%HICPE==2,,	;3.2 CHANNEL CONTROL WORD PARITY ERROR
DEFSYM	%HINXM==1,,	;3.1 CHANNEL NXM ERROR

;CONI - RIGHT HALF

DEFSYM	%HIBPE==400000	;2.9 DATA BUSS PARITY ERROR
DEFSYM	%HIEXC==200000	;2.8 "EXCEPTION" IN DRIVE DURING DATA TRANSFER
DEFSYM	%HICER==100000	;2.7 CHANNEL ERROR (OR OF 3 BITS IN LH)
DEFSYM	%HICWW==040000	;2.6 CONTROL WORD HAS BEEN WRITTEN
DEFSYM	%HIOVR==020000	;2.5 OVER-RUN (MEMORY DATA LATE)
DEFSYM	%HIDRE==010000	;2.4 DRIVE RESPONSE ERROR - NO RESPONSE FROM DRIVE
DEFSYM	%HIILC==004000	;2.3 ILLEGAL COMMAND OR REGISTER ACCESS ERROR
DEFSYM	%HIPWR==002000	;2.2 POWER FAIL
DEFSYM	%HICOV==000200	;1.8 CONTROL BUS OVER-RUN
DEFSYM	%HIRAE==000100	;1.7 REGISTER ACCESS ERROR (ONLY IF INTR ENB)
DEFSYM	%HIATN==000040	;1.6 ATTENTION (INTERRUPTS)
DEFSYM	%HIBSY==000020	;1.5 CONTROL BUSY WITH DATA TRANSFER
DEFSYM	%HIDON==000010	;1.4 DATA TRANSFER DONE, NORMAL OR ERROR
			;1.1-1.3 PIA AS USUAL
DEFSYM	%HIERR==736300	;CONI ERROR BITS

;CONO

			;2.7-2.9 CLEAR CORRESPONDING ERROR BITS
DEFSYM	%HOWCW==040000	;2.6 WRITE CONTROL WORD
			;2.3-2.5 CLEAR CORRESPONDING ERROR BITS
DEFSYM	%HORST==002000	;2.2 RESET THE CONTROLLER
			;1.8 CLEARS CORRESPONDING ERROR BIT
DEFSYM	%HORAE==000100	;1.7 ENABLE RAE TO INTERRUPT
DEFSYM	%HOATN==000040	;1.6 ENABLE ATTENTION TO INTERRUPT
DEFSYM	%HOSTP==000020	;1.5 STOP DATA TRANSFER, CLR BSY, SET DONE
			;1.4 CLEARS CORRESP BIT (DONE)
			;1.1-1.3 SET PIA
DEFSYM	%HOCLR==734210	;CONO TO CLEAR ALL ERROR BITS

;CONTROLLER REGISTER NUMBERS (LH OF DATAO)

DEFSYM	%HRLOD==1_13		;4.3 BIT TO SAY "LOAD SELECTED REGISTER"
DEFSYM	%HRCTL==40_14		;CONTROL REGISTER
DEFSYM	 $HCDRV==.BP <7,,>	;3.1-3.3 DRIVE SELECT FIELD
DEFSYM	 $HCICWA==.BP 077700	;1.7-2.6 INITIAL CONTROL WORD ADDR
				;AS USUAL, 1.7 IS REALLY THE WRITE EVEN PARITY BIT
				;1.1-1.6 FUNCTION CODE (%HMxxx) AND GO BIT
DEFSYM	%HRBUF==50_14		;DATA BUFFER REGISTER (MAINTENANCE)
DEFSYM	%HRIAD==44_14		;INTERRUPT ADDRESS REGISTER
				;3.2 1=>KI-10 MODE, 0=>KA-10 MODE
				;1.1-1.9 9-BIT VECTOR ADDRESS (KI)
DEFSYM	%HRRAE==54_14		;REGISTER ACCESS ERROR REGISTER
				;DATAI 1.1-1.8 RAE DRIVE 0-7
				;DATAO 1.1-1.8 CLEAR THAT BIT
DEFSYM	%HRCBF==74_14		;CHANNEL BUFFER

;COMMANDS
; COMMANDS THAT DO I/O ARE PUT IN %HRCTL ALONG WITH $HCICWA
; OTHER COMMANDS ARE STORED INTO %HRDCL
; IN EITHER CASE $HCDRV SAYS WHICH DRIVE

DEFSYM	%HMNOP==0	;NO OPERATION
DEFSYM	%HMUNL==3	;UNLOAD (DOES PACK FLY OFF?)
DEFSYM	%HMREC==7	;RECALIBRATE
DEFSYM	%HMCLR==11	;DRIVE CLEAR (RESET ERRORS ETC.)
DEFSYM	%HMRLS==13	;DRIVE RELEASE (DUAL PORT)
DEFSYM	%HMSRC==31	;SEARCH (FOR R.P.S.)
DEFSYM	%HMWCH==51	;WRITE CHECK -- DOESN'T WORK (DEC BRAIN DAMAGE)
DEFSYM	%HMWCF==53	;WRITE CHECK FORMAT (HEADER AND DATA) -- DOESN'T WORK
DEFSYM	%HMWRT==61	;WRITE DATA
DEFSYM	%HMWHD==63	;WRITE HEADER AND DATA (FORMAT THE PACK)
DEFSYM	%HMRED==71	;READ DATA
DEFSYM	%HMRHD==73	;READ HEADER AND DATA
DEFSYM	%HMSEK==5	;SEEK TO CYLINDER
DEFSYM	%HMOFS==15	;OFFSET HEADS SLIGHTLY
DEFSYM	%HMCEN==17	;RETURN HEADS TO CENTERLINE
DEFSYM	%HMACK==23	;ACKNOWLEDGE MOUNTING OF PACK (REQUIRED BEFORE I/O)
DEFSYM	%HMRDP==21	;"READ-IN PRESET"

;STANDARD FIELDS IN DRIVE REGISTERS

				;3.1-3.3 DRIVE NUMBER ($HCDRV)
DEFSYM	%HDCBT==002000		;4.2 CONTROL BUS TIMEOUT
DEFSYM	%HDPAR==001000		;4.1 MASS BUS CONTROL PARITY ERROR
DEFSYM	%HDDLT==000400		;3.9 DATA LATE (NEED 3 US BETWEEN DATAO AND DATAI)
DEFSYM	%HDILC==000200		;3.8 ILLEGAL COMMAND
DEFSYM	%HDERR==003600		;ALL BITS FOR ERRORS IN TALKING TO DRIVE
 ;DRIVE-DEPENDENT DATA IS IN LOW 16 BITS (1.1-2.7)

;DRIVE REGISTERS (NUMBER IN LH OF DATAO)

DEFSYM	%HRDCL==0_14	;DRIVE CONTROL REGISTER
			;1.1-1.6 COMMAND (%HMxxx) 1.1=GO BIT
DEFSYM	 %HCDVA==1_11.	;2.3 DRIVE AVAILABLE

DEFSYM	%HRSTS==1_14	;STATUS REGISTER
			;1.1-1.6 BITS ON DURING HEAD LOAD SEQUENCE
DEFSYM	 %HSVV==100	;1.7 VOLUME VALID.  SET BY %HMACK, CLEARED BY
			;    DRIVE TURN ON.  0 => PACK MAY HAVE BEEN CHANGED
DEFSYM	 %HSRDY==200	;1.8 DRIVE READY
DEFSYM	 %HSDPR==400	;1.9 "DRIVE PRESET" = CONNECTED TO THIS CONTROLLER
DEFSYM	 %HSPGM==1000	;2.1 "PROGRAMMABLE" = EITHER CTRLR CAN CONNECT
DEFSYM	 %HSLST==2000	;2.2 LAST SECTOR TRANSFERRED
DEFSYM	 %HSWRL==4000	;2.3 WRITE LOCK
DEFSYM	 %HSMOL==10000	;2.4 MEDIUM ON-LINE
DEFSYM	 %HSPIP==20000	;2.5 POSITIONING IN PROGRESS
DEFSYM	 %HSERR==40000	;2.6 BIT ON %HRER1, %HRER2, OR %HRER3
DEFSYM	 %HSATN==100000	;2.7 ATTENTION - ERROR, POSITIONING COMPLETE,
			;     STARTUP COMPLETE, OR DRIVE AVAILABLE

DEFSYM	%HRER1==2_14	;ERROR REGISTER 1
			;GENERALLY THESE BITS ARE ONLY RESET BY %HMCLR
			;1.1 ILLEGAL COMMAND IN %HRDCL
			;1.2 ATTEMPT TO ACCESS NON-EXISTENT DRIVE REGISTER
			;1.3 ATTEMPT TO WRITE IN DRIVE REGISTER WHILE DRIVE BUSY
			;1.4 PARITY ERROR ON MASSBUS
			;1.5 FORMAT ERROR (PACK & CPU NOT BOTH 16- OR BOTH 18-BIT)
			;1.6 WRITE CLOCK FAIL
DEFSYM	 %H1ECH==100	;1.7 ECC HARD ERROR (NOT 11-BIT BURST)
			;1.8 HEADER COMPARE ERROR
			;1.9 HEADER CRC ERROR
			;2.1 ADDRESS OVERFLOW
			;2.2 INVALID ADDRESS
DEFSYM	 %H1WLK==4000	;2.3 ATTEMPT TO WRITE WHILE WRITE-LOCKED
			;2.4 DRIVE TIMING ERROR.  MAY DE-FORMAT THE TRACK.
			;2.5 OPERATION NOT COMPLETE (3 REVS NO ACTION)
			;2.6 DRIVE UNSAFE - WRITE LOCK OR FIELD SERVICE
DEFSYM	 %H1ECC==100000	;2.7 DATA CHECK, ECC COMPUTATION INITIATED
DEFSYM	 %H1SOF==110730	;SOFT ERRORS

DEFSYM	%HRMNT==3_14	;MAINTENANCE REGISTER (SEE RP04 MAINT MANUAL)

DEFSYM	%HRATN==4_14	;ATTENTION SUMMARY REGISTER (NOT REALLY PER-DRIVE)
			;1.1-1.8 %HSATN DRIVES 0-7
			;CLEARED BY ACCESSING DRIVE OR WRITING A 1

DEFSYM	%HRADR==5_14		;DESIRED SECTOR/TRACK ADDRESS
DEFSYM	 $HATRK==.BP 17400 	;TRACK 0-22 OCTAL
DEFSYM	 $HASEC==.BP 37		;SECTOR 0-23 OCTAL (128 WORDS EACH)
				 ;NOTE THESE FIELDS ARE 8-BITS EACH

DEFSYM	%HRLAH==7_14	;LOOK AHEAD (READ ONLY)
			;NUMBER OF 64'THS OF A SECTOR

DEFSYM	%HRTYP==6_14	;DRIVE TYPE (RO)
			;1.1-1.9 DRIVE TYPE NUMBER (20 FOR "RP04")
			;2.3 DUAL-PORT DRIVE
			;2.5 MOVING HEAD
			;2.6 TAPE
			;2.7 NOT BLOCK ADDRESSED

DEFSYM	%HRSER==10_14	;DRIVE SERIAL NUMBER (RO)

DEFSYM	%HROFS==11_14	;HEAD OFFSET
			;1.1-1.8 OFFSET CODE
			;1.9-2.7 MISC CRUFTIES

DEFSYM	%HRCYL==12_14	;DESIRED CYLINDER ADDRESS
			; 0 TO 410 DECIMAL

DEFSYM	%HRCCY==13_14	;CURRENT CYLINDER ADDRESS

DEFSYM	%HRER2==14_14	;ERROR REGISTER 2
			;MISC UNSAFE CONDITIONS IN DRIVE

DEFSYM	%HRER3==15_14	;ERROR REGISTER 3
			;1.1-1.7 MORE MISC UNSAFES IN DRIVE
DEFSYM	 %H3SKI==40000	;2.6 SEEK INCOMPLETE
DEFSYM	 %H3OFC==100000	;2.7 OFF CYLINDER

DEFSYM	%HRPOS==16_14	;ECC POSITION
			;LOCATION OF ERROR BURST WITHIN SECTOR

DEFSYM	%HRPAT==17_14	;ECC PATTERN
			;11-BIT ERROR BURST

;DF10-C CHANNEL DEFINITIONS (22-BIT- (KI-) MODE)

DEFSYM	$DFCAD==002600,,	;CURRENT ADDRESS - 1 (IN CONTROL WORD)
DEFSYM	$DFWC==261600,,		;- WORD COUNT (IN CONTROL WORD)
DEFSYM	$DFLAD==002600,,	;LAST DATA ADDRESS (IN STORED CONTROL WD)
DEFSYM	$DFCWA==261600,,	;LAST CONTROL WORD ADDRESS (IN STORED CONTROL WORD)



IFN $$TEMP,EXPUNG DEFSYM
